import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

// 导入树形表格插件
import ZkTable from 'vue-table-with-tree-grid'

// 导入axios
import axios from 'axios'

// 富文本编辑器相关设置
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

// 设置默认请求路径
axios.defaults.baseURL = 'http://115.159.87.220:8888/api/private/v1/'

// 请求拦截器设置请求头
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem('token')
  return config
})

// 挂载到原型
Vue.prototype.$axios = axios

// 设置树形表格组件
Vue.component('tree-table', ZkTable)

Vue.config.productionTip = false

// 过滤时间过滤器
Vue.filter('formatTime', (time) => {
  const newDate = new Date(time * 1000)
  const y = newDate.getFullYear()
  const m = (newDate.getMonth() + 1).toString().padStart(2, 0)
  const d = newDate.getDate().toString().padStart(2, 0)
  return y + '-' + m + '-' + d
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
